package com.glepoch.springbootsecuritymybatis.bean;

import com.glepoch.springbootsecuritymybatis.compoment.constant.statuscode.BaseStatusEnum;
import com.glepoch.springbootsecuritymybatis.compoment.constant.statuscode.NormalStatusCode;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.NonNull;

import java.io.Serializable;

/**
 * @description: 统一响应数据实体基础类
 * @author: ygl
 * @time: 20201204
 */
@Data
@AllArgsConstructor
@NoArgsConstructor

//@ApiModel(description = "统一响应数据实体基础类")
public class BaseResultVO<T> implements Serializable {
    //@ApiModelProperty("响应码")
    @NonNull
    private int code;
    //@ApiModelProperty("提示消息")
    @NonNull
    private String message;

    public static  BaseResultVO success(int code, String message) {
        return new BaseResultVO(code, message);
    }

    public static  BaseResultVO success(String message) {
        return success(NormalStatusCode.SUCCESS.getCode(), message);
    }


    public static  BaseResultVO success(BaseStatusEnum baseStatusEnum) {
        return new BaseResultVO(baseStatusEnum.getCode(), baseStatusEnum.getMessage());
    }

    public static  BaseResultVO success() {
        return new BaseResultVO(NormalStatusCode.SUCCESS.getCode(), NormalStatusCode.SUCCESS.getMessage());
    }

    public static  BaseResultVO fail(int code, String message) {
        return new BaseResultVO(code, message);
    }

    public static  BaseResultVO fail(BaseStatusEnum baseStatusEnum) {
        return fail(baseStatusEnum.getCode(), baseStatusEnum.getMessage());
    }

    public static  BaseResultVO fail(String message) {
        return fail(NormalStatusCode.FAIL.getCode(), message);
    }

    public static  BaseResultVO fail() {
        return fail(NormalStatusCode.FAIL.getCode(), NormalStatusCode.FAIL.getMessage());
    }
}
